<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>添加项目</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
</head>
<body>
<div class="layui-fluid">
		<div class="layui-card">
			<div class="layui-card-body">
			<div class="layui-form-item">
		      <div class="layui-input-inline">
		        <!-- 使用隐藏域用于保存编辑项的ID值，便于提交修改 -->
		            <input type="hidden" name="projectid" id="projectid">
		      </div>
		    </div>
				<table class="layui-hide" id="test" lay-filter="test"></table>
				<div id="demo"></div>
				<script type="text/html" id="buttonTpl">
         			 {{#  if(d.status){ }}
           				 <button class="layui-btn layui-btn-xs">已发布</button>
          			 {{#  } else { }}
           			 	<button class="layui-btn layui-btn-primary layui-btn-xs">待修改</button>
          			 {{#  } }}
       			 </script>
			</div>
		</div>
	</div>
	<input type="text" id="id" style="display:none">
	<script src="../../layui/layui.js"></script>
 <script>
layui.use(['table','jquery','form'],function(){
   var table = layui.table;
   var form = layui.form;
   var $ = layui.jquery
   var project = $('#projectid').val();//获取值
   
   $('#searchBtn').on('click',function(){
         var type = $(this).data('type');
         active[type] ? active[type].call(this) : '';
     });   
     var param = '?projectid=' + project;
  //表格渲染
  table.render({
    elem: '#test'
    ,url:'../../grouping/getgroupmdList'+param
    ,response: {
	    statusName: 'code' //规定数据状态的字段名称，默认：code
	    ,statusCode: 0 //规定成功的状态码，默认：0
	    ,msgName: 'msg' //规定状态信息的字段名称，默认：msg
	    ,countName: 'count' //规定数据总数的字段名称，默认：count
	    ,dataName: 'data' //规定数据列表的字段名称，默认：data
  	} 
    ,toolbar: '#toolbarDemo'
    ,title: '项目数据表'
    ,id:'test'
    ,cols: [[
      {type: 'checkbox', fixed: 'left'}
      ,{field:'projectname', title:'项目名称'}
      ,{field:'groupname', title:'组别'}
      ,{field:'athletesname', title:'运动员姓名'}
    ]]
    ,page: true
  });
  
  
  //头工具栏事件
  table.on('toolbar(test)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id);
    switch(obj.event){
      case 'getCheckData':
        var data = checkStatus.data;
        layer.alert(JSON.stringify(data));
      break;
      case 'getCheckLength':
        var data = checkStatus.data;
        layer.msg('选中了：'+ data.length + ' 个');
      break;
      case 'isAll':
        layer.msg(checkStatus.isAll ? '全选': '未全选');
      break;
    };
  });
 });
</script>
  
</body>
</html>